﻿using System;
using System.IO;
using System.Collections.Generic;

namespace Beaup.UnitTests
{
    public abstract class UnitTester : IUnitTester
    {
        #region UnitError
        protected class UnitError
        {
            private int _line;
            private string _error;

            public UnitError(int lineNo, string command)
            {
                _line = lineNo;
                _error = command;
            }

            public UnitError(int lineNo, List<string> command)
            {
                _line = lineNo;
                _error = string.Empty;
                foreach (string item in command)
                {
                    _error += item + Environment.NewLine;
                }
            }

            public string LineNumber
            {
                get
                {
                    return _line.ToString();
                }
            }

            public string Error
            {
                get { return _error; }
            }

            public override string ToString()
            {
                string errStr = _line.ToString() + ": " + _error;
                return errStr;
            }
        }
        #endregion

        protected FileInfo _unitTestFile;
        protected LinkedList<UnitError> _errors;
        protected bool _passed;

        protected UnitTester()
        {
            _passed = true;
        }

        public virtual bool Passed
        {
            get { return _passed; }
        }

        #region IUnitTester Members

        public abstract void RunTest();
        public abstract void PrintErrors();
        public abstract void PrintResults();
        
        #endregion
    }
}
